package com.tfxy.hxl.config;

import io.swagger.v3.oas.annotations.enums.SecuritySchemeType;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.servers.Server;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class GatewaySwaggerConfig {

    @Value("${spring.application.name}")
    private String gatewayName;

    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("网关聚合接口文档: " + gatewayName)
                        .description("聚合所有微服务的接口文档")
                        .version("1.0"));
    }

    // 可选：按需分组展示 API
    @Bean
    public GroupedOpenApi userApi() {
        return GroupedOpenApi.builder()
                .group("用户服务")
                .pathsToMatch("/user/**")
                .build();
    }

    @Bean
    public GroupedOpenApi activityApi() {
        return GroupedOpenApi.builder()
                .group("活动服务")
                .pathsToMatch("/activity/**")
                .build();
    }

    @Bean
    public GroupedOpenApi bookingApi() {
        return GroupedOpenApi.builder()
                .group("预约服务")
                .pathsToMatch("/booking/**")
                .build();
    }

    @Bean
    public GroupedOpenApi venueApi() {
        return GroupedOpenApi.builder()
                .group("场馆服务")
                .pathsToMatch("/venue/**")
                .build();
    }
    @Bean
    public GroupedOpenApi coachApi() {
        return GroupedOpenApi.builder()
                .group("教练服务")
                .pathsToMatch("/coach/**")
                .build();
    }

}
